<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="../js/code.js"></script>
</head>

<body>

</body>
<script>
  var cookie = document.cookie;
  if (cookie) {
    var user = getCookie("lgc");  //登录的用户名
    if (user) {
      document.write(`<span>欢迎您,${user}</span><button onclick="exit()">退出</button>`);
    } else {
      document.write('<a href="./login.html">亲,请登录</a>');
    }
  }


  function exit() {
    delCookie("lgc");
    location.reload();
  }
</script>

</html>